<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8"/>
	<meta name="keywords" content="text encoding, encoding, detection"/>
	<link rel="stylesheet" href="../../Shared/sty/standard.css"/>
	<script defer src="../../Shared/js/toc.js"></script>
	
	<title>Use encoding declarations for encoding detection in CotEditor on Mac</title>
</head>

<body>

<h1>Use encoding declarations for encoding detection in CotEditor on Mac</h1>

<p>When the “Refer to encoding declaration in document” option in Format settings is selected, CotEditor checks for encoding declarations when opening a file. The following declaration forms are recognized if present: <code>charset=</code>, <code>encoding=</code>, <code>@charset</code>, <code>encoding:</code> and <code>coding:</code>. If one of these declarations is written properly, CotEditor uses it to determine the file’s text encoding.</p>
<p>A declaration can appear anywhere in the document. CotEditor detects it whether it is inside a comment or written as plain text. If you need to include wording such as “charset=UTF-8” even though the document is not actually encoded in UTF-8, either place the correct encoding declaration before that phrase or turn off the “Refer to encoding declaration in document” option.</p>

<ul>
	<li><p>The scope to scan declarations is limited to 2,000 characters from the head of the document.</p></li>
	<li><p>To make the detection of declarations work, you have to put an equal sign (“=”, no other characters) right after “<code>charset</code>” or “<code>encoding</code>.”</p></li>
	<li><p>The encoding name which comes after “<code>charset=</code>” or “<code>encoding=</code>” can be without double-quotes (&quot;) around.</p></li>
	<li><p>In the case there are multiple encoding declarations in your document, CotEditor uses the first one to determine the text encoding.</p></li>
</ul>


<section id="cf">
<h2>See also</h2>
<ul>
	<li><a href="settings_format.html">Change Format settings in CotEditor on Mac</a></li>
	<li><a href="howto_customize_encoding_order.html">Change priorities of text encodings in CotEditor on Mac</a></li>
	<li><a href="about_shiftjis.html">Use four kinds of Shift JIS properly in CotEditor on Mac</a></li>
</ul>
</section>

</body>
</html>
